#include "widget.h"
#include "ui_widget.h"
#include "switchcontrol.h"
#include <qDebug>

Widget::Widget(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::Widget)
{
    ui->setupUi(this);

    SwitchControl *pSwitchControl = new SwitchControl(this);
    SwitchControl *pGreenSwitchControl = new SwitchControl(this);
    SwitchControl *pDisabledSwitchControl = new SwitchControl(this);

    // 设置状态、样式
    pGreenSwitchControl->setToggle(true);
    pGreenSwitchControl->setCheckedColor(QColor(0, 160, 230));
    pDisabledSwitchControl->setDisabled(true);
    pDisabledSwitchControl->setToggle(true);

    // 连接信号槽
    connect(pSwitchControl, SIGNAL(toggled(bool)), this, SLOT(onToggled(bool)));
}

void Widget::onToggled(bool bChecked)
{
    qDebug() << "State : " << bChecked;
}

Widget::~Widget()
{
    delete ui;
}
